/**
 * 登录用Action
 */
package teatime.core.web.action;

import java.util.Date;

import teatime.core.model.entity.Account;
import teatime.core.model.entity.Event;
import teatime.core.service.manager.AccountManager;
import teatime.core.service.manager.EventManager;
import teatime.core.web.action.base.BaseAction;

/**
 * @author ShenJie
 * @since 2008-04-16
 */
@SuppressWarnings("serial")
public class EventAction extends BaseAction {

	private String eventName;
	private String eventType;
	
	private Event event;
	private Account account;

	private EventManager<Event> eventManager;
	private AccountManager<Account> accountManager;

	public String getEventName() {
		return eventName;
	}

	public void setEventName(String eventName) {
		this.eventName = eventName;
	}

	public String getEventType() {
		return eventType;
	}

	public void setEventType(String eventType) {
		this.eventType = eventType;
	}

	public void setEventManager(EventManager<Event> eventManager) {
		this.eventManager = eventManager;
	}

	public Event getEvent() {
		return event;
	}

	public void setEvent(Event event) {
		this.event = event;
	}

	public void setAccountManager(AccountManager<Account> accountManager) {
		this.accountManager = accountManager;
	}
	
	/**
	 * 
	 */
	public String execute() throws Exception {
		try {
			if (event == null) {
				event = new Event();
			}
			event.setEventName(eventName);
			event.setCreateDate(new Date());
			account = accountManager.findUniqueBy("Id", 1);
			eventManager.save(event);
			setResponse(SUCCESS);
		} catch (Exception ex) {
			setResponse(ERROR);
		}
		return null;
	}
}
